import {Component, EventEmitter, OnInit, Output} from '@angular/core';
import {Msg} from '../msg';

@Component({
  selector: 'app-fund',
  templateUrl: './fund.component.html',
  styleUrls: ['./fund.component.css']
})
export class FundComponent implements OnInit {

  @Output()
  lastPrice = new EventEmitter<Msg>();

  constructor() {
    setInterval(() => {
      this.msg.price += Math.random() * 2 - 1;
      this.msg.time = new Date();
      this.lastPrice.emit(this.msg);
    }, 1000);
  }

  private msg = new Msg(100, new Date());

  ngOnInit() {
  }

}
